package fnord.jovian.tango;

import fnord.jovian.TheBoard;
import fnord.jovian.tango.TheAssemblyLayout.TheAssemblyOrientation;

public class TheStartMenu extends TheMenu {

	public TheStartMenu(TheBoard board) {
		super(300,300,board);
		TheAssemblyLayout layout = new TheAssemblyLayout(TheAssemblyOrientation.VERTICAL);
		setTheLayout(layout);
		this.addComponent(new TheButton("Host a Game", 200, 30, new TheHostListener()));
		this.addComponent(new TheButton("Join a Game", 200, 30, new TheJoinListener()));
		this.addComponent(new TheButton("Settings", 200, 30, new TheSettingsListener()));
		this.addComponent(new TheButton("Quit FNORD", 200, 30, new TheQuitListener()));
	}

	private class TheQuitListener implements TheListener {
		public void doAction() {
			System.exit(0);
		}
	}

	private class TheHostListener implements TheListener {
		public void doAction() {
			_board.getCommunicator().launchServer();
			_board.toggleLobby();
		}
	}

	private class TheJoinListener implements TheListener {
		public void doAction() {
			_board.getCommunicator().launchClient();
			_board.toggleLobby();
		}
	}

	private class TheSettingsListener implements TheListener {
		public void doAction() {
			_board.toggleSettings();
			_board.repaint();
		}
	}

}
